import { defineStore } from 'pinia'
import type { RouteRecordRaw } from 'vue-router'
import { computed, ref } from 'vue'
import { routes } from '@/router'

interface MenuState {
  menuList?: RouteRecordRaw[]
  setMenuList: (val: RouteRecordRaw[]) => void
  getMenuList: () => RouteRecordRaw[]
}

export const useMenuStore = defineStore('menu', (): MenuState => {
  const menuList = ref<RouteRecordRaw[]>([...routes])

  const setMenuList = (val: RouteRecordRaw[]) => {
    menuList.value = [...routes, ...val]
  }

  const getMenuList = () => {
    return menuList.value
  }

  return { getMenuList, setMenuList }
})
